package com.luyuan.wxapp.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.luyuan.common.annotation.Anonymous;
import com.luyuan.common.core.domain.AjaxResult;
import com.luyuan.common.core.page.TableDataInfo;
import com.luyuan.system.domain.SysNotice;
import com.luyuan.system.service.ISysNoticeService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 微信小程序通知公告Controller
 * 
 * @author luyuan
 */
@Api(value = "微信小程序通知公告接口", tags = "wx_notice")
@RestController
@RequestMapping("/wxapp/notice")
public class WxappExhiNoticeController extends WxBaseController{

    @Autowired
    private ISysNoticeService noticeService;

    /**
     * 获取通知公告列表
     */
    @Anonymous
    @ApiOperation(value = "获取通知公告列表", notes = "获取通知公告列表", nickname = "listNotice")
    @GetMapping("/list")
    public TableDataInfo list(SysNotice notice) {
        // 只显示状态为正常的公告
        notice.setStatus("0");
        startPage();
        List<SysNotice> list = noticeService.selectNoticeList(notice);
        return getDataTable(list);
    }

    /**
     * 根据通知公告编号获取详细信息
     */
    @ApiOperation(value = "获取通知公告详情", notes = "根据通知公告编号获取详细信息", nickname = "getNotice")
    @GetMapping(value = "/{noticeId}")
    public AjaxResult getInfo(@PathVariable Long noticeId) {
        return AjaxResult.success(noticeService.selectNoticeById(noticeId));
    }
}